package com.example.books.program

/**
 * @title: Marker
 * @projectName bigdata
 * @Version: 1.0
 * @description: TODO
 * @author leali
 * @date 2022/6/1 0:01
 */
class Marker(val color: String) {
  println(s"Creating $this")

  override def toString: String = s"marker color $color"
}

object Marker {
  private val markers: Map[String, Marker] = Map(
    "red" -> new Marker("red"),
    "blue" -> new Marker("blue"),
    "green" -> new Marker("green")
  )

  def getMarker(color: String): Marker = {
    //    if(markers.contains(color)) markers(color) else null
    markers.getOrElse(color, null)
  }
}